{include file = "header.html"}

<link rel="stylesheet" href="js/cooltips/tooltips.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/prototype/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous/src/scriptaculous.js?load=builder,effects"></script>
<script type="text/javascript" src="js/scriptaculous/src/effects.js"></script>
<script type="text/javascript" src="js/cooltips/tooltips.js"></script>
<script type="text/javascript" src="js/poll.js"></script>
<script type="text/javascript" src="js/poll_tooltips.js"></script>

<div id = "content">
  <p id="title">{$title}</p>
  <p id="description">{$description}</p>
<!--  <p> <b> Share URL: </b> <a href='poll.php?poll_id={$poll_id}'>Here</a></p> -->
  <br/>
  <div class = "submit-form">
    <form action="process_poll_results.php?poll_id={$poll_id}" method="post" onsubmit="return validate(this)">
      <input type="hidden" name="maxselect" value="{$maxselect}" />
      <input type="hidden" name="numchoices" value="{count($poll_options)}" />
      <div id="options">
        <table id="results">
          <thead>
            <tr>
              <td>&nbsp;</td>
	      {section name=options loop=$poll_options}
	      <td>{$poll_options[options].choice}</td>
              {/section}
	      <td>Comments</td>
            </tr>
	  </thead>
        
          <tfoot>
	    <tr>
	      <td class="name">Total</td>
              {section name=total loop=$totals}
	      <td>{$totals[total]}</td>
              {/section}
	    </tr>
          </tfoot>
        
          <tbody>
            {section name=name loop=$results}
	    <tr>
              <td class="name">{$results[name]['name']}</td>
	      {section name=color loop=$results[name].choice}
	      <td class={if $results[name].choice[color] eq 1}"yes"{else}"no"{/if}></td>
              {/section}
              <td class="other">
		{if strlen($results[name].other) > 30} 
		  {substr($results[name].other, 0, 30)}<a class="comment_tooltip" title="<b>{$results[name]['name']}:</b> {$results[name].other}" href="#">...</a>
		{else} 
		  {$results[name].other} 
		{/if}
	      </td>
	      <script type="text/javascript" charset="utf-8">
		$$("td .comment_tooltip").each( function(input) {
		new Tooltip(input);});
	      </script>
	    </tr>
	    {/section} 
            <tr>
	      <td class="name"><input id="option_username" type="text" name="name" value="{$username}" /></td>
              {section name=values loop=$poll_options}
              <td><input type="checkbox" name="choice[{$smarty.section.values.index}]" value="{$poll_options[values]['value']}" /></td>
	      {/section}
	      <td><input id="option_other" type="text" name="other" value="{$other}" /></td>
	    </tr>
          </tbody>
        </table>
        <br />
        <p class="center"> <input class="submit" type="submit" value="Submit" /> </p>
      </div>
    </form>
  {if $maxselect > 0}
  <p>Please check at most <b>{$maxselect} option(s)</b>.</p>
  {/if}
  </div>
</div>

{include file = "footer.html"}
